package main
{
	import api.dataStruct.GameApiInfo;
	import api.dataStruct.InitAPIObj;
	import api.dataStruct.ReadStoreVO;
	import api.dataStruct.ServerStoreVO;
	import api.event.CallFunName;
	
	import base.GlobalData;
	
	import com.game.api.APICore;
	import com.game.display.AutoGCMovieClip;
	import com.game.display.DisManage;
	
	import mc.InitAPIBg;
	
	public class InitAPI extends AutoGCMovieClip
	{
		private var _apiCore:APICore=APICore.getInstance();
		public function InitAPI()
		{
			init();
		}
		private function init():void{
			DisManage.delAllDis();
			DisManage.addDis(new InitAPIBg());
			GlobalData.apiCore.currClass=(this);
			GlobalData.apiCore.startAPI(GlobalData.getInitAPIObj());
		}
		public function initAPIcom(myInfo:GameApiInfo):void{
			GlobalData.myInfo=myInfo;
			if(GlobalData.apiType==InitAPIObj.TYPE_1||GlobalData.apiType==InitAPIObj.TYPE_2){
				new InitAPI_PVP();
			}else if(GlobalData.apiType==InitAPIObj.TYPE_5){
				_apiCore.callAPIFun(CallFunName.A_READ_STORE,new ReadStoreVO(2,1,onGetStoreVO,"读取用户数据"));
			}else if(GlobalData.apiType==InitAPIObj.TYPE_6){
				new Title();
			}
		}
		private function onGetStoreVO(storeVO:ServerStoreVO=null):void{
			new Title();
		}
		public function startGame(data:Boolean):void{
			DisManage.delAllDis();
			_apiCore.isRobot=GlobalData.isRobot=data;
			DisManage.addDis(new Game()); 
		}
		
	}
}